// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** 新增单个数据,并返回新增后的数据. POST /user */
export async function add(body: API.UserEntity, options?: { [key: string]: any }) {
  return request<API.UserEntity>('/user', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 保存数据 如果传入了id,并且对应数据存在,则尝试覆盖,不存在则新增. PATCH /user */
export async function save(body: API.UserEntity[], options?: { [key: string]: any }) {
  return request<API.SaveResult>('/user', {
    method: 'PATCH',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 批量新增数据 POST /user/_batch */
export async function add1(body: API.UserEntity[], options?: { [key: string]: any }) {
  return request<number>('/user/_batch', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 使用GET方式查询总数 GET /user/_count */
export async function count2(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.count2Params,
  options?: { [key: string]: any },
) {
  return request<number>('/user/_count', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 使用POST方式查询总数 POST /user/_count */
export async function count(body: API.QueryParamEntity, options?: { [key: string]: any }) {
  return request<number>('/user/_count', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 使用GET方式判断数据是否存在 GET /user/_exists */
export async function exists2(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.exists2Params,
  options?: { [key: string]: any },
) {
  return request<boolean>('/user/_exists', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 使用POST方式判断数据是否存在 POST /user/_exists */
export async function exists(body: API.QueryParamEntity, options?: { [key: string]: any }) {
  return request<boolean>('/user/_exists', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 使用GET方式分页动态查询 GET /user/_query */
export async function queryPager2(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.queryPager2Params,
  options?: { [key: string]: any },
) {
  return request<API.PagerResultUserEntity>('/user/_query', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 使用POST方式分页动态查询 POST /user/_query */
export async function queryPager(body: API.QueryParamEntity, options?: { [key: string]: any }) {
  return request<API.PagerResultUserEntity>('/user/_query', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 使用GET方式分页动态查询(不返回总数) 此操作不返回分页总数,如果需要获取全部数据,请设置参数paging=false GET /user/_query/no-paging */
export async function query2(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.query2Params,
  options?: { [key: string]: any },
) {
  return request<API.UserEntity[]>('/user/_query/no-paging', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 使用POST方式分页动态查询(不返回总数) 此操作不返回分页总数,如果需要获取全部数据,请设置参数paging=false POST /user/_query/no-paging */
export async function query(body: API.QueryParamEntity, options?: { [key: string]: any }) {
  return request<API.UserEntity[]>('/user/_query/no-paging', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 根据ID查询 GET /user/${param0} */
export async function getById(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.getByIdParams,
  options?: { [key: string]: any },
) {
  const { id: param0, ...queryParams } = params;
  return request<API.UserEntity>(`/user/${param0}`, {
    method: 'GET',
    params: { ...queryParams },
    ...(options || {}),
  });
}

/** 根据ID修改数据 PUT /user/${param0} */
export async function update(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.updateParams,
  body: API.UserEntity,
  options?: { [key: string]: any },
) {
  const { id: param0, ...queryParams } = params;
  return request<boolean>(`/user/${param0}`, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    params: { ...queryParams },
    data: body,
    ...(options || {}),
  });
}

/** 根据ID删除 DELETE /user/${param0} */
export async function deleteUsingDelete(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.deleteUsingDELETEParams,
  options?: { [key: string]: any },
) {
  const { id: param0, ...queryParams } = params;
  return request<API.UserEntity>(`/user/${param0}`, {
    method: 'DELETE',
    params: { ...queryParams },
    ...(options || {}),
  });
}
